﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{

    class Program

    {
        public enum Fist
        {
            剪刀 = 1,
            石头,
            布
        }
        public static string name;
        static int x = 0;
        static int y = 0;
        static int sum = x+y;
        static string npc = null;
        private static object yes;
        private static object no;

        static void Main(string[] args)
        {
            Console.WriteLine("-----------------------欢迎进入游戏世界---------------");
            Console.WriteLine("******************************");
            Console.WriteLine("**********猜拳，开始**********");
            Console.WriteLine("******************************");
            Console.WriteLine("出拳规则：1.剪刀 2.石头 3.布");
            Console.WriteLine("请选择对方角色：<1：刘备 2：孙策 3：曹操>");
            int key = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入您的名字：");
            name = Console.ReadLine();
            
            
            switch (key)
            {
                case 1:
                    npc = "刘备";
                    Console.WriteLine($"{name} VS {npc} 对战");
                    break;
                case 2:
                    npc = "孙策";
                    Console.WriteLine(name + "VS" + "孙策   对战");
                    break;
                case 3:
                    npc = "曹操";
                    Console.WriteLine(name + "VS" + "曹操   对战");
                    break;

                default:
                    break;
            }  
            Task1(npc);
            Task2();




        }

        private static void  Task2()
        {
            Console.WriteLine("是否要开始下一局？<yes.no>");
            string xyj = Console.ReadLine();
            switch (xyj)
            {
                case "yes":
                    Fist a = userFist();
                    Fist b = npcFist();
                    Console.WriteLine(name + ": 出拳：{0}", a);
                    Console.WriteLine(npc+": 出拳：{0}",b);
                    int c = (int)a;
                    int d = (int)b;
                    Task(c, d);
                    Task2();
                    break;
                case "no":
                    Console.WriteLine("===============================");
                    Console.WriteLine($"{npc}VS{name}");
                    Console.WriteLine("姓名    得分");
                    Console.WriteLine("{0}", name);
                    Console.WriteLine("{0}", npc);
                    Console.WriteLine($"结果：{name}赢，{npc}输");
                    Console.WriteLine("要开下一局吗？");
                    Task2();
                    break;
              
                   
                    

                    

                    
                default:
                    break;
            }

        }

       

        static Fist npcFist()
        {
            Random red = new Random();
            int s = red.Next(1, 4);
            Fist fist = (Fist)s;
            return fist;
        }
        static Fist userFist()
        {

            Console.WriteLine("请出拳：1.剪刀 2.石头 3.布(输入相应数字)");
            int b = int.Parse(Console.ReadLine());
            Fist fist = (Fist)b;
            return fist;
        }

        private static void Task1(string npc)
        {
            Console.WriteLine("开始游戏？<yes.no>");
            string yn = Console.ReadLine();
            if (yn.Equals ("yes"))
            {
            Fist a = userFist();
            Fist b = npcFist();
            Console.WriteLine(name + ": 出拳：{0}", a);
            Console.WriteLine($"{npc}: 出拳：{b}");
            int c = (int)a;
            int d = (int)b;
            Task(c, d);
            }
            else if (yn.Equals("no"))
            {
                Console.WriteLine("===============================");
                Console.WriteLine($"{npc}VS{name}");
                Console.WriteLine("姓名    得分");
                Console.WriteLine($"{name}  {x}");
                Console.WriteLine($"{npc}  {y}");
                Console.WriteLine("结果：{name}赢，{npc}输");
                Console.WriteLine("要开下一局吗？");
                Task2();



            }
          

        }

        private static void Task(int a, int b)
        {
            if (a == b)
            {
                Console.WriteLine("和局，嘿嘿，等着瞧");
            }
            else if ((a == 1 && b == 2) || (a == 2 && b == 3)|| (a == 3 && b == 1))
            {
                Console.WriteLine($"恭喜{name}赢");
                x += 1;
            }
            else
            {
                Console.WriteLine("输");
                y += 1;
            }
        }



















    }
}
